package com.tedu.charging.service.user.controller;

import com.tedu.charging.common.pojo.web.ServerResult;
import com.tedu.charging.service.user.service.IChargingUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class WeiXinLoginController {

    @Autowired
    IChargingUserInfoService chargingUserInfoService;


    @GetMapping("/wx/login")
    /**
     * 手机调用本接口
     * code:临时token
     * nickname:呢称
     */
    public ServerResult<Integer> wxLogin(@RequestParam("code") String code, String nickName) throws Throwable {

        Integer userId = chargingUserInfoService.wxLogin(code, nickName);

        return new ServerResult<Integer>(0,"success",userId);

    }
}
